package com.example.safehome;
import java.util.Random;

public class WaterInSensor
{
    //系统状态
    private boolean systemStatus;
    //水位超标地点
    private String waterInPosition;
    //是否发生水位超标
    private static boolean isWaterIn = false;
    //是否运行
    private static boolean isRunning = true;
    //水位超标数组
    private String[]Position ={"阳台","客厅","卧室1","卧室2","卫生间1","卫生间2","饭厅","厨房"};


    WaterInSensor()
    {
        systemStatus=true;
        waterInPosition="";
    }
    //监测设备运行状态
    public boolean getStatus()
    {
        return systemStatus;
    }

    public boolean isWaterIn() {
        return isWaterIn;
    }

    //获取水位超标地点
    public String getWaterInPosition()
    {
        return waterInPosition;
    }

    //报警
    public void ringAlarm()
    {
        voiceWarn();
        callPolice();
        callHost();
    }

    //鸣响驱逐警报
    public void voiceWarn()
    {
        return;
    }

    //通知警察
    public void callPolice()
    {
        java.lang.System.out.println("拨打110");
    }

    //通知用户
    public void callHost()
    {

    }
    //水位超标检测是否运行
    public boolean isDetect()
    {
        return isRunning;
    }
    //水位超标检测是否退出
    public boolean isQuit()
    {
        return !isRunning;
    }
    //运行水位超标检测
    public void detect()
    {
        if (getStatus())
        {
            isRunning=true;
            if (isWaterIn)
            {
                getWaterInPosition();
                ringAlarm();
            }
        }
    }
    //退出水位超标检测检测
    public void quit()
    {
        isRunning=false;
    }
    //测试生成水位超标
    public void test() {
        Random RandomPosition = new Random();
        waterInPosition=Position[RandomPosition.nextInt(Position.length-1)];
        isWaterIn=true;

    }
    //异常处理
    public boolean exceptionHandle()
    {
        return true;
    }


}
